package org.example.egmvc1.controller;

import org.example.egmvc1.mapper.EmpMapper;
import org.example.egmvc1.pojo.empdto.EmpDto;
import org.example.egmvc1.pojo.entity.Emp;
import org.example.egmvc1.pojo.vo.EmpVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/emp")
public class EmpController {
    @Autowired
    private EmpMapper empMapper;

    @RequestMapping("/select")
    public List<EmpVO> empVOList(){

        return empMapper.selectEmp();
    }

    @RequestMapping("/insert")
    public int anInt(EmpDto empDto){
        Emp emp = new Emp();
        BeanUtils.copyProperties(empDto,emp);

        return empMapper.insertEmp(emp);
    }

}
